import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'mobx-react';
import { Tools } from 'weaver-mobile';
import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom';
import { asyncComponent } from 'react-async-component';
import { FloatingTouch, DocumentTitle } from 'weaver-mobile-page';
// import FastClick from 'fastclick';

import allStore from './stores';
import './style';

const coms = {
  AccountSetting: asyncComponent({
    resolve: () => import("./components/accountSetting")
  }),
  Main: asyncComponent({
    resolve: () => import("./components/index")
  })
}

const Root = () => {
  const data = [
    {match: /^\/accountSetting/i, title: () => Tools.getLabel(19667,'账号设置')},
  ];
  return (
    <Provider {...allStore}>
      <Router>
        <FloatingTouch homeBtnTips="">
          <DocumentTitle data={data} defaultTitle="" />
          <Route
            name="home"
            path="/"
            render={props => (
              <Switch>
                <Route name="accountSetting" path="/accountSetting" component={coms.AccountSetting} />
                <Route name="main" path="/main" component={coms.Main} />
                <Redirect to="/main" />
              </Switch>
            )}
          />
        </FloatingTouch>
      </Router>
    </Provider>
  )
};

Tools.getLocaleLabel('integration_mobile', () => {
  render(<Root />, document.getElementById('root'));
});